package com.eastfair.projectcore.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.projectcore.enumeration.MenuMenuTypeEnum;
import com.eastfair.projectcore.enumeration.MenuAffiliationEnum;
import com.eastfair.projectcore.enumeration.MenuSceneEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 菜单
 * </p>
 *
 * @author ligang
 * @since 2023-05-11
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("c_menu")
@ApiModel(value = "Menu", description = "菜单")
@AllArgsConstructor
public class Menu extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 菜单名称
     */
    @ApiModelProperty(value = "菜单名称")
    @Size(max = 255, message = "菜单名称长度不能超过255")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "菜单名称")
    private String name;

    /**
     * 菜单名称（英文）
     */
    @ApiModelProperty(value = "菜单名称（英文）")
    @Size(max = 255, message = "菜单名称（英文）长度不能超过255")
    @TableField(value = "en_name", condition = LIKE)
    @Excel(name = "菜单名称（英文）")
    private String enName;

    /**
     * code码
     */
    @ApiModelProperty(value = "code码")
    @NotEmpty(message = "请填写code码")
    @Size(max = 255, message = "code码长度不能超过255")
    @TableField(value = "code", condition = LIKE)
    @Excel(name = "code码")
    private String code;

    /**
     * 菜单类型 #{CATALOG:目录;MENU:菜单;BUTTON:按钮}
     */
    @ApiModelProperty(value = "菜单类型 #{CATALOG:目录;MENU:菜单;BUTTON:按钮}")
    @TableField(value = "menu_type")
    @Excel(name = "菜单类型 #{CATALOG:目录;MENU:菜单;BUTTON:按钮}", replace = {"目录_CATALOG", "菜单_MENU", "按钮_BUTTON",  "_null"})
    private MenuMenuTypeEnum menuType;

    /**
     * 值例如：www.baidu  / 内联地址，内链则是前端用的路由地址
     */
    @ApiModelProperty(value = "值例如：www.baidu  / 内联地址，内链则是前端用的路由地址")
    @Size(max = 255, message = "值例如：www.baidu  / 内联地址，内链则是前端用的路由地址长度不能超过255")
    @TableField(value = "link", condition = LIKE)
    @Excel(name = "值例如：www.baidu  / 内联地址，内链则是前端用的路由地址")
    private String link;

    /**
     * 路由参数
     */
    @ApiModelProperty(value = "路由参数")
    @Size(max = 255, message = "路由参数长度不能超过255")
    @TableField(value = "link_param", condition = LIKE)
    @Excel(name = "路由参数")
    private String linkParam;

    /**
     * 组件路径,前端资源路径，给前端用的
     */
    @ApiModelProperty(value = "组件路径,前端资源路径，给前端用的")
    @Size(max = 255, message = "组件路径,前端资源路径，给前端用的长度不能超过255")
    @TableField(value = "module_url", condition = LIKE)
    @Excel(name = "组件路径,前端资源路径，给前端用的")
    private String moduleUrl;

    /**
     * 权限字符
     */
    @ApiModelProperty(value = "权限字符")
    @Size(max = 255, message = "权限字符长度不能超过255")
    @TableField(value = "permission", condition = LIKE)
    @Excel(name = "权限字符")
    private String permission;

    /**
     * 接口权限
     */
    @ApiModelProperty(value = "接口权限")
    @Size(max = 1255, message = "接口权限长度不能超过1255")
    @TableField(value = "interface_url", condition = LIKE)
    @Excel(name = "接口权限")
    private String interfaceUrl;

    /**
     * icon
     */
    @ApiModelProperty(value = "icon")
    @Size(max = 255, message = "icon长度不能超过255")
    @TableField(value = "icon", condition = LIKE)
    @Excel(name = "icon")
    private String icon;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @TableField(value = "sequence")
    @Excel(name = "排序")
    private Integer sequence;

    /**
     * 父级id
     */
    @ApiModelProperty(value = "父级id")
    @NotNull(message = "请填写父级id")
    @TableField(value = "parent_id")
    @Excel(name = "父级id")
    private Long parentId;

    /**
     * 是否外链(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否外链(默认1：是 0:否)")
    @TableField(value = "is_out_link")
    @Excel(name = "是否外链(默认1：是 0:否)")
    private Integer isOutLink;

    /**
     * 是否显示(默认1：是 0:否)
     */
    @ApiModelProperty(value = "是否显示(默认1：是 0:否)")
    @TableField(value = "is_show")
    @Excel(name = "是否显示(默认1：是 0:否)")
    private Integer isShow;

    /**
     * 是否生效(默认1：可用 0:不可用)
     */
    @ApiModelProperty(value = "是否生效(默认1：可用 0:不可用)")
    @TableField(value = "is_enabled")
    @Excel(name = "是否生效(默认1：可用 0:不可用)")
    private Integer isEnabled;

    /**
     * 是否删除(默认0：未删除 1:已删除)
     */
    @ApiModelProperty(value = "是否删除(默认0：未删除 1:已删除)")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除(默认0：未删除 1:已删除)")
    private Integer isDeleted;

    /**
     * 归属系统#{P:厦门智慧场馆;P_VENUE:场馆业务管理系统;P_CERTIFICATE:证件管理系统;P_COMPOSITE_VENUE:综合-场馆管理; P_COMPOSITE_COURT:综合-主场管理;P_COMPOSITE_PRODUCER:综合-搭建商管理;P_COMPOSITE_TRANSPORT:综合-主运管理;P_COMPOSITE_TRADE:综合-商旅管理;P_COMPOSITE_MATING:综合-配套商管理;P_PAY:支付系统;P_EXHIBITOR_SELF:展商自服务;P_CATERINGAPP:餐饮小程序;P_CATERING:餐饮后台服务;P_PORTAL_OUT_VENUE:对外门户-场馆后台;P_PORTAL_OUT_OPERATION:对外门户-运营后台;P_PORTAL_IN_WORK:内部门户-工作后台;P_PORTAL_IN_WORKAPP:内部门户-工作APP;P_OPERATION_CENTER:智慧运营中心系统;P_VISITOR_FRONT:访客前台系统;P_VISITOR_BACK:访客后台系统}
     */
    @ApiModelProperty(value = "归属系统#{P:厦门智慧场馆;P_VENUE:场馆业务管理系统;P_CERTIFICATE:证件管理系统;P_COMPOSITE_VENUE:综合-场馆管理; P_COMPOSITE_COURT:综合-主场管理;P_COMPOSITE_PRODUCER:综合-搭建商管理;P_COMPOSITE_TRANSPORT:综合-主运管理;P_COMPOSITE_TRADE:综合-商旅管理;P_COMPOSITE_MATING:综合-配套商管理;P_PAY:支付系统;P_EXHIBITOR_SELF:展商自服务;P_CATERINGAPP:餐饮小程序;P_CATERING:餐饮后台服务;P_PORTAL_OUT_VENUE:对外门户-场馆后台;P_PORTAL_OUT_OPERATION:对外门户-运营后台;P_PORTAL_IN_WORK:内部门户-工作后台;P_PORTAL_IN_WORKAPP:内部门户-工作APP;P_OPERATION_CENTER:智慧运营中心系统;P_VISITOR_FRONT:访客前台系统;P_VISITOR_BACK:访客后台系统}")
    @TableField(value = "affiliation")
    @Excel(name = "归属系统#{P:厦门智慧场馆;P_VENUE:场馆业务管理系统;P_CERTIFICATE:证件管理系统;P_COMPOSITE_VENUE:综合-场馆管理; P_COMPOSITE_COURT:综合-主场管理;P_COMPOSITE_PRODUCER:综合-搭建商管理;P_COMPOSITE_TRANSPORT:综合-主运管理;P_COMPOSITE_TRADE:综合-商旅管理;P_COMPOSITE_MATING:综合-配套商管理;P_PAY:支付系统;P_EXHIBITOR_SELF:展商自服务;P_CATERINGAPP:餐饮小程序;P_CATERING:餐饮后台服务;P_PORTAL_OUT_VENUE:对外门户-场馆后台;P_PORTAL_OUT_OPERATION:对外门户-运营后台;P_PORTAL_IN_WORK:内部门户-工作后台;P_PORTAL_IN_WORKAPP:内部门户-工作APP;P_OPERATION_CENTER:智慧运营中心系统;P_VISITOR_FRONT:访客前台系统;P_VISITOR_BACK:访客后台系统}", replace = {"厦门智慧场馆_P", "场馆业务管理系统_P_VENUE", "证件管理系统_P_CERTIFICATE", "综合-场馆管理_P_COMPOSITE_VENUE", "综合-主场管理_P_COMPOSITE_COURT", "综合-搭建商管理_P_COMPOSITE_PRODUCER", "综合-主运管理_P_COMPOSITE_TRANSPORT", "综合-商旅管理_P_COMPOSITE_TRADE", "综合-配套商管理_P_COMPOSITE_MATING", "支付系统_P_PAY", "展商自服务_P_EXHIBITOR_SELF", "餐饮小程序_P_CATERINGAPP", "餐饮后台服务_P_CATERING", "对外门户-场馆后台_P_PORTAL_OUT_VENUE", "对外门户-运营后台_P_PORTAL_OUT_OPERATION", "内部门户-工作后台_P_PORTAL_IN_WORK", "内部门户-工作APP_P_PORTAL_IN_WORKAPP", "智慧运营中心系统_P_OPERATION_CENTER", "访客前台系统_P_VISITOR_FRONT", "访客后台系统_P_VISITOR_BACK",  "_null"})
    private MenuAffiliationEnum affiliation;

    /**
     * 场景#{MANAGE:后台菜单;WORK:工作台菜单;APP:前端菜单;}
     */
    @ApiModelProperty(value = "场景#{MANAGE:后台菜单;WORK:工作台菜单;APP:前端菜单;}")
    @TableField(value = "scene")
    @Excel(name = "场景#{MANAGE:后台菜单;WORK:工作台菜单;APP:前端菜单;}", replace = {"后台菜单_MANAGE", "工作台菜单_WORK", "前端菜单_APP",  "_null"})
    private MenuSceneEnum scene;


    @Builder
    public Menu(Long id, LocalDateTime createTime, Long createdBy, LocalDateTime updateTime, Long updatedBy, 
                    String name, String enName, String code, MenuMenuTypeEnum menuType, String link, 
                    String linkParam, String moduleUrl, String permission, String interfaceUrl, String icon, Integer sequence, 
                    Long parentId, Integer isOutLink, Integer isShow, Integer isEnabled, Integer isDeleted, MenuAffiliationEnum affiliation, MenuSceneEnum scene) {
        this.id = id;
        this.createTime = createTime;
        this.createdBy = createdBy;
        this.updateTime = updateTime;
        this.updatedBy = updatedBy;
        this.name = name;
        this.enName = enName;
        this.code = code;
        this.menuType = menuType;
        this.link = link;
        this.linkParam = linkParam;
        this.moduleUrl = moduleUrl;
        this.permission = permission;
        this.interfaceUrl = interfaceUrl;
        this.icon = icon;
        this.sequence = sequence;
        this.parentId = parentId;
        this.isOutLink = isOutLink;
        this.isShow = isShow;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.affiliation = affiliation;
        this.scene = scene;
    }

}
